<template>
  
    <li :key="item.id" @click="playMusic">
      <slot></slot>
      <div class="left">
        <span :class="{ active: num == 0 || num == 1 || num == 2 }">{{
        num+1|formatNum}}</span>
      </div>
      <div class="middle">
        <div class="name">{{ item.name }}</div>
        <p>
          <span :class="{ active: item.song.privilege.maxbr > 320000 }"></span
          >{{ item.song.artists[0].name }}-{{ item.name }}
        </p>
      </div>
      <div class="right">
        <span></span>
      </div>
    </li>
    
  
</template>
<script>
export default {
    props:{
      item:Object,
      num:{
        type:Number,
        default:0
      }
    },
    methods:{
        playMusic(){
          //把音乐ID传递给Vue实例里面playingMusic属性.
          this.$root.playingMusic.musicID=this.item.id;
          this.$root.playingMusic.isShow = true;
          // console.log(this.$root,this.$parent);
        }
    },
    filters:{
      formatNum(val){
        return val<10?"0"+val:val;
      }
    }
}
</script>
<style lang="less" scoped>
  li {
    display: flex;
    // margin-top: 10px;
    // padding-left: 5px;
    .left {
      display: flex;
      font-size: 17px;
      align-items: center;
      padding: 0 5px;
      span {
        display: inline-block;
        width: 22px;
        height: 22px;
        color: #999;
        &.active {
          color: #df3436;
        }
      }
    }
    .middle {
      text-align: left;
      flex: 1;
      border-bottom: 1px solid #ddd;
      padding: 6px 0;
      .name {
        color: #000;
        padding-bottom: 3px;
        font-size: 17px;
      }
      p {
        color: #888;
        font-size: 12px;
        // padding: 5px 0;
        span.active {
          display: inline-block;
          padding: 0 2px;
          background: url(../assets/index_icon_2x.png) no-repeat 0 0;
          background-size: 166px 97px;
          width: 12px;
          height: 8px;
        }
      }
    }
    .right {
      display: flex;
      align-items: center;
      padding: 0 10px;
      border-bottom: 1px solid #ddd;
      span {
        display: inline-block;
        width: 22px;
        height: 22px;
        background: url(../assets/index_icon_2x.png) no-repeat -24px 0;
        background-size: 166px 97px;
      }
    }
  }
</style>